﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LIMS.Entities;
using Castle.Core.Logging;

namespace LIMS.Shared
{
    public class GLITSPagePresenter : BasePresenter<IGLITSPageView>
    {
        private IGLITSPageView view;

        private ILogger Logger;
        public GLITSPagePresenter(IGLITSPageView view,ILogger oLogger)
            : base(view)
        {
            this.view = view;
            this.Logger = oLogger;
        }
        /// <summary>
        /// Initialize view by binding grid through setter.
        /// </summary>
        /// <returns></returns>
        public bool InitializeView()
        {
            try
            {
                GridViewData ogrdData = view.GridData;
                view.GridData = ogrdData;
                return true;
            }
            catch (Exception ex)
            {
                Logger.Error("Error while initializing> Error : " + ex.Message, ex);
                return false;
            }
        }
        

        public bool Edit(int index)
        {
            try
            {
                view.CurrentIndex = index;
                return true;
            }
            catch (Exception ex)
            {
                Logger.Error("Error occured while editing record. Exception : " + ex.Message, ex);
                return false;
            }
        }
    }
}
